package routers

import (
	"github.com/gin-gonic/gin"
	"xm_shop/controllers/admin"
	"xm_shop/controllers/tool"
)

func InitAdminRouters(r *gin.Engine) {
	adminRouter := r.Group("/admin")
	{
		// 1. 登录部分
		adminRouter.GET("/captcha", admin.LoginController{}.Captcha)
		adminRouter.POST("/login", admin.LoginController{}.Login)
		adminRouter.POST("/captcha", admin.LoginController{}.VerifyCaptcha)
		// 2. 角色部分
		adminRouter.GET("/role/:id", admin.RoleController{}.GetOnlyRole)
		adminRouter.GET("/roleAllAccess", admin.RoleController{}.GetRoleAccess)
		adminRouter.GET("/role", admin.RoleController{}.GetRole)
		// 角色授权
		adminRouter.POST("/role/auth", admin.RoleController{}.Auth)
		adminRouter.POST("/role", admin.RoleController{}.AddRole)
		adminRouter.PUT("/role/:id/", admin.RoleController{}.EditRole)
		adminRouter.DELETE("/role/:id", admin.RoleController{}.DelRole)

		// 3. 管理员部分
		adminRouter.POST("/manager", admin.ManagerController{}.AddManager)
		adminRouter.GET("/manager/:id", admin.ManagerController{}.GetOnlyManager)
		adminRouter.GET("/manager", admin.ManagerController{}.GetManager)
		adminRouter.PUT("/manager/:id/", admin.ManagerController{}.EditManager)
		adminRouter.DELETE("/manager/:id", admin.ManagerController{}.DelManager)

		// 4. 访问权限部分
		adminRouter.GET("/access/:id", admin.AccessController{}.GetOnlyAccess)
		adminRouter.GET("/access", admin.AccessController{}.GetModule)
		adminRouter.GET("/accessAndChild", admin.AccessController{}.GetModuleAndChild)
		adminRouter.POST("/access", admin.AccessController{}.Add)
		adminRouter.PUT("/access/:id/", admin.AccessController{}.Edit)
		adminRouter.DELETE("/access/:id", admin.AccessController{}.Delete)

		// 5. 公共部分
		adminRouter.GET("/main", admin.MainController{}.Index)
		adminRouter.PUT("/ChangeStatus/:id/", admin.MainController{}.ChangeStatus)
		adminRouter.PUT("/ChangeSort/:id/", admin.MainController{}.ChangeSort)
		adminRouter.GET("/flushAll", admin.MainController{}.FlushAll)

		// 6. 轮播图部分
		adminRouter.POST("/focus", admin.FocusController{}.Add)
		adminRouter.GET("/focus/:id", admin.FocusController{}.GetOnlyFocus)
		adminRouter.GET("/focus", admin.FocusController{}.Index)
		adminRouter.PUT("/focus/:id/", admin.FocusController{}.Edit)
		adminRouter.DELETE("/focus/:id", admin.FocusController{}.Delete)

		// 商品分类部分
		adminRouter.GET("/getAllTopCate", admin.GoodsCateController{}.GetAllTopCate)
		adminRouter.GET("/cate/index", admin.GoodsCateController{}.Index)
		adminRouter.POST("/cate/add", admin.GoodsCateController{}.Add)
		adminRouter.PUT("/cate/:id", admin.GoodsCateController{}.Edit)
		adminRouter.DELETE("/cate/:id", admin.GoodsCateController{}.Delete)

		// 商品类型部分
		adminRouter.GET("/type", admin.GoodsTypeController{}.Index)
		adminRouter.POST("/type", admin.GoodsTypeController{}.Add)
		adminRouter.PUT("/type/:id", admin.GoodsTypeController{}.Edit)
		adminRouter.DELETE("/type/:id", admin.GoodsTypeController{}.Delete)

		// 商品类型属性部分
		adminRouter.GET("/attr/:id", admin.GoodsTypeAttributeController{}.GetOnlyGoodsTypeAttribute)
		adminRouter.GET("/getTypeAllAttr", admin.GoodsTypeAttributeController{}.Index)
		adminRouter.POST("/attr", admin.GoodsTypeAttributeController{}.Add)
		adminRouter.PUT("/attr/:id/", admin.GoodsTypeAttributeController{}.Edit)
		adminRouter.DELETE("/attr/:id", admin.GoodsTypeAttributeController{}.Delete)

		// 图片处理类
		adminRouter.GET("/t1", tool.DefaultController{}.Thumbnail1)
		adminRouter.GET("/t2", tool.DefaultController{}.Thumbnail2)
		adminRouter.GET("/t3", tool.DefaultController{}.Thumbnail3)
		adminRouter.GET("/t4", tool.DefaultController{}.Thumbnail4)
		adminRouter.POST("/upload_img", tool.DefaultController{}.UploadImg)

		// 商品类
		adminRouter.POST("/goods/uploadImage", admin.GoodsController{}.ImageUpload)
		adminRouter.GET("/goods/color", admin.GoodsController{}.GetAllColor)
		adminRouter.POST("/goods/add", admin.GoodsController{}.Add)
		adminRouter.GET("/goods/index", admin.GoodsController{}.Index)
		adminRouter.GET("/goods/:id", admin.GoodsController{}.GetOnlyGoods)
		adminRouter.PUT("/goods/:id/", admin.GoodsController{}.Edit)
		adminRouter.GET("/goodsImage", admin.GoodsController{}.ChangeGoodsImageColor)
		adminRouter.DELETE("/goodsImage/:id", admin.GoodsController{}.RemoveGoodsImage)
		adminRouter.DELETE("/goods/:id", admin.GoodsController{}.RemoveGoods)

		// 导航栏
		adminRouter.POST("/nav", admin.NavController{}.Add)
		adminRouter.GET("/nav/index", admin.NavController{}.Index)
		adminRouter.GET("/nav/:id", admin.NavController{}.GetOnlyNav)
		adminRouter.PUT("/nav/:id/", admin.NavController{}.Edit)
		adminRouter.DELETE("/nav/:id", admin.NavController{}.Delete)

		// 设置类
		adminRouter.GET("/setting", admin.SettingController{}.Index)
		adminRouter.POST("/setting", admin.SettingController{}.Edit)
	}
}
